package com.duolebo.uteped_sdk.model;

import android.annotation.SuppressLint;
import android.content.ContentValues;
import android.database.Cursor;

import com.yc.nadalsdk.bean.WorkoutData;

import java.util.ArrayList;

/**
 * @Author: wudapeng
 * @Date: 2023/12/20 16:50
 * @Description:
 */
public class WorkoutModel extends BaseModel {
    /**
     * 格式 ：yyyyMMddHHmmss
     */
    private String startTime;
    /**
     * 格式 ：yyyyMMddHHmmss
     */
    private String endTime;
    /**
     * 格式 ：yyyyMMdd
     */
    private String calendar;
    private int step;
    private int distance;
    private float calories;
    private int heart;
    private int maxHeart;
    private int minHeart;
    private int count;
    private int duration;
    /**
     * 运动类型，具体见 WorkoutType
     */
    private int sportsType;
    /**
     * 配速，单位：秒/公里
     */
    private int pace;
    /**
     * 平均速度，单位：分米/秒
     */
    private int verSpeed;
    private int frequency;
    /**
     * 步幅，单位：厘米
     */
    private int stride;
    private int longestStreak;
    private int tripped;
    private int jumpRopeFrequency;
    private int swimType;
    private int swimPoolLength;
    private int tripTimes;
    private int swimAverageSwolf;
    private int altitude;
    private int highestAltitude;
    private int lowestAltitude;
    private int totalRiseHeight;
    private int totalDropHeight;
    private int floorsUp;
    private int floorsDown;
    private int pullTime;
    private int freeTime;
    private int sportId;
    private String gpsDataList;
    private String detailDataList;


    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public String getCalendar() {
        return calendar;
    }

    public void setCalendar(String calendar) {
        this.calendar = calendar;
    }

    public int getStep() {
        return step;
    }

    public void setStep(int step) {
        this.step = step;
    }

    public int getDistance() {
        return distance;
    }

    public void setDistance(int distance) {
        this.distance = distance;
    }

    public float getCalories() {
        return calories;
    }

    public void setCalories(float calories) {
        this.calories = calories;
    }

    public int getHeart() {
        return heart;
    }

    public void setHeart(int heart) {
        this.heart = heart;
    }

    public int getMaxHeart() {
        return maxHeart;
    }

    public void setMaxHeart(int maxHeart) {
        this.maxHeart = maxHeart;
    }

    public int getMinHeart() {
        return minHeart;
    }

    public void setMinHeart(int minHeart) {
        this.minHeart = minHeart;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public int getDuration() {
        return duration;
    }

    public void setDuration(int duration) {
        this.duration = duration;
    }

    public int getSportsType() {
        return sportsType;
    }

    public void setSportsType(int sportsType) {
        this.sportsType = sportsType;
    }

    public int getPace() {
        return pace;
    }

    public void setPace(int pace) {
        this.pace = pace;
    }

    public int getVerSpeed() {
        return verSpeed;
    }

    public void setVerSpeed(int verSpeed) {
        this.verSpeed = verSpeed;
    }

    public int getFrequency() {
        return frequency;
    }

    public void setFrequency(int frequency) {
        this.frequency = frequency;
    }

    public int getStride() {
        return stride;
    }

    public void setStride(int stride) {
        this.stride = stride;
    }

    public int getLongestStreak() {
        return longestStreak;
    }

    public void setLongestStreak(int longestStreak) {
        this.longestStreak = longestStreak;
    }

    public int getTripped() {
        return tripped;
    }

    public void setTripped(int tripped) {
        this.tripped = tripped;
    }

    public int getJumpRopeFrequency() {
        return jumpRopeFrequency;
    }

    public void setJumpRopeFrequency(int jumpRopeFrequency) {
        this.jumpRopeFrequency = jumpRopeFrequency;
    }

    public int getSwimType() {
        return swimType;
    }

    public void setSwimType(int swimType) {
        this.swimType = swimType;
    }

    public int getSwimPoolLength() {
        return swimPoolLength;
    }

    public void setSwimPoolLength(int swimPoolLength) {
        this.swimPoolLength = swimPoolLength;
    }

    public int getTripTimes() {
        return tripTimes;
    }

    public void setTripTimes(int tripTimes) {
        this.tripTimes = tripTimes;
    }

    public int getSwimAverageSwolf() {
        return swimAverageSwolf;
    }

    public void setSwimAverageSwolf(int swimAverageSwolf) {
        this.swimAverageSwolf = swimAverageSwolf;
    }

    public int getAltitude() {
        return altitude;
    }

    public void setAltitude(int altitude) {
        this.altitude = altitude;
    }

    public int getHighestAltitude() {
        return highestAltitude;
    }

    public void setHighestAltitude(int highestAltitude) {
        this.highestAltitude = highestAltitude;
    }

    public int getLowestAltitude() {
        return lowestAltitude;
    }

    public void setLowestAltitude(int lowestAltitude) {
        this.lowestAltitude = lowestAltitude;
    }

    public int getTotalRiseHeight() {
        return totalRiseHeight;
    }

    public void setTotalRiseHeight(int totalRiseHeight) {
        this.totalRiseHeight = totalRiseHeight;
    }

    public int getTotalDropHeight() {
        return totalDropHeight;
    }

    public void setTotalDropHeight(int totalDropHeight) {
        this.totalDropHeight = totalDropHeight;
    }

    public int getFloorsUp() {
        return floorsUp;
    }

    public void setFloorsUp(int floorsUp) {
        this.floorsUp = floorsUp;
    }

    public int getFloorsDown() {
        return floorsDown;
    }

    public void setFloorsDown(int floorsDown) {
        this.floorsDown = floorsDown;
    }

    public int getPullTime() {
        return pullTime;
    }

    public void setPullTime(int pullTime) {
        this.pullTime = pullTime;
    }

    public int getFreeTime() {
        return freeTime;
    }

    public void setFreeTime(int freeTime) {
        this.freeTime = freeTime;
    }

    public int getSportId() {
        return sportId;
    }

    public void setSportId(int sportId) {
        this.sportId = sportId;
    }

    public String getGpsDataList() {
        return gpsDataList;
    }

    public void setGpsDataList(String gpsDataList) {
        this.gpsDataList = gpsDataList;
    }

    public String getDetailDataList() {
        return detailDataList;
    }

    public void setDetailDataList(String detailDataList) {
        this.detailDataList = detailDataList;
    }

    public WorkoutModel() {}

    /**
     * BaseModel
     *
     * @param model model
     */
    WorkoutModel(BaseModel model) {
        super(model);
    }



    @Override
    public void writeFieldValues(ContentValues values) {
        super.writeFieldValues(values);
        values.put(WorkoutFields.START_TIME, startTime);
        values.put(WorkoutFields.END_TIME, endTime);
        values.put(WorkoutFields.CALENDAR, calendar);
        values.put(WorkoutFields.STEP, step);
        values.put(WorkoutFields.DISTANCE, distance);
        values.put(WorkoutFields.CALORIES, calories);
        values.put(WorkoutFields.HEART, heart);
        values.put(WorkoutFields.MAX_HEART, maxHeart);
        values.put(WorkoutFields.MIN_HEART, minHeart);
        values.put(WorkoutFields.COUNT, count);
        values.put(WorkoutFields.DURATION, duration);
        values.put(WorkoutFields.SPORTS_TYPE, sportsType);
        values.put(WorkoutFields.PACE, pace);
        values.put(WorkoutFields.VER_SPEED, verSpeed);
        values.put(WorkoutFields.FREQUENCY, frequency);
        values.put(WorkoutFields.STRIDE, stride);
        values.put(WorkoutFields.LONGEST_STREAK, longestStreak);
        values.put(WorkoutFields.TRIPPED, tripped);
        values.put(WorkoutFields.JUMP_ROPE_FREQUENCY, jumpRopeFrequency);
        values.put(WorkoutFields.SWIM_TYPE, swimType);
        values.put(WorkoutFields.SWIM_POOL_LENGTH, swimPoolLength);
        values.put(WorkoutFields.TRIP_TIMES, tripTimes);
        values.put(WorkoutFields.SWIM_AVERAGE_SWOLF, swimAverageSwolf);
        values.put(WorkoutFields.ALTITUDE, altitude);
        values.put(WorkoutFields.HIGHEST_ALTITUDE, highestAltitude);
        values.put(WorkoutFields.LOWEST_ALTITUDE, lowestAltitude);
        values.put(WorkoutFields.TOTAL_RISE_HEIGHT, totalRiseHeight);
        values.put(WorkoutFields.TOTAL_DROP_HEIGHT, totalDropHeight);
        values.put(WorkoutFields.FLOORS_UP, floorsUp);
        values.put(WorkoutFields.FLOORS_DOWN, floorsDown);
        values.put(WorkoutFields.PULL_TIME, pullTime);
        values.put(WorkoutFields.FREE_TIME, freeTime);
        values.put(WorkoutFields.SPORT_ID, sportId);
        values.put(WorkoutFields.GPS_DATA, gpsDataList);
        values.put(WorkoutFields.DETAIL_DATA, detailDataList);
    }

    @SuppressLint("Range")
    @Override
    public void readFieldValues(Cursor c) {
        super.readFieldValues(c);
        startTime = c.getString(c.getColumnIndex(WorkoutFields.START_TIME));
        endTime = c.getString(c.getColumnIndex(WorkoutFields.END_TIME));
        calendar = c.getString(c.getColumnIndex(WorkoutFields.CALENDAR));
        step = c.getInt(c.getColumnIndex(WorkoutFields.STEP));
        distance = c.getInt(c.getColumnIndex(WorkoutFields.DISTANCE));
        calories = c.getInt(c.getColumnIndex(WorkoutFields.CALORIES));
        heart = c.getInt(c.getColumnIndex(WorkoutFields.HEART));
        maxHeart = c.getInt(c.getColumnIndex(WorkoutFields.MAX_HEART));
        minHeart = c.getInt(c.getColumnIndex(WorkoutFields.MIN_HEART));
        count = c.getInt(c.getColumnIndex(WorkoutFields.COUNT));
        duration = c.getInt(c.getColumnIndex(WorkoutFields.DURATION));
        sportsType = c.getInt(c.getColumnIndex(WorkoutFields.SPORTS_TYPE));
        pace = c.getInt(c.getColumnIndex(WorkoutFields.PACE));
        verSpeed = c.getInt(c.getColumnIndex(WorkoutFields.VER_SPEED));
        frequency = c.getInt(c.getColumnIndex(WorkoutFields.FREQUENCY));
        stride = c.getInt(c.getColumnIndex(WorkoutFields.STRIDE));
        longestStreak = c.getInt(c.getColumnIndex(WorkoutFields.LONGEST_STREAK));
        tripped = c.getInt(c.getColumnIndex(WorkoutFields.TRIPPED));
        jumpRopeFrequency = c.getInt(c.getColumnIndex(WorkoutFields.JUMP_ROPE_FREQUENCY));
        swimType = c.getInt(c.getColumnIndex(WorkoutFields.SWIM_TYPE));
        swimPoolLength = c.getInt(c.getColumnIndex(WorkoutFields.SWIM_POOL_LENGTH));
        tripTimes = c.getInt(c.getColumnIndex(WorkoutFields.TRIP_TIMES));
        swimAverageSwolf = c.getInt(c.getColumnIndex(WorkoutFields.SWIM_AVERAGE_SWOLF));
        altitude = c.getInt(c.getColumnIndex(WorkoutFields.ALTITUDE));
        highestAltitude = c.getInt(c.getColumnIndex(WorkoutFields.HIGHEST_ALTITUDE));
        lowestAltitude = c.getInt(c.getColumnIndex(WorkoutFields.LOWEST_ALTITUDE));
        totalRiseHeight = c.getInt(c.getColumnIndex(WorkoutFields.TOTAL_RISE_HEIGHT));
        totalDropHeight = c.getInt(c.getColumnIndex(WorkoutFields.TOTAL_DROP_HEIGHT));
        floorsUp = c.getInt(c.getColumnIndex(WorkoutFields.FLOORS_UP));
        floorsDown = c.getInt(c.getColumnIndex(WorkoutFields.FLOORS_DOWN));
        pullTime = c.getInt(c.getColumnIndex(WorkoutFields.PULL_TIME));
        freeTime = c.getInt(c.getColumnIndex(WorkoutFields.FREE_TIME));
        sportId = c.getInt(c.getColumnIndex(WorkoutFields.SPORT_ID));
        gpsDataList = c.getString(c.getColumnIndex(WorkoutFields.GPS_DATA));
        detailDataList = c.getString(c.getColumnIndex(WorkoutFields.DETAIL_DATA));
    }

    @Override
    public void prepareFieldDefs(ArrayList<String> fieldDefs) {
        super.prepareFieldDefs(fieldDefs);
        fieldDefs.add(WorkoutFields.START_TIME + FIELD_TYPE_TEXT);
        fieldDefs.add(WorkoutFields.END_TIME + FIELD_TYPE_TEXT);
        fieldDefs.add(WorkoutFields.CALENDAR + FIELD_TYPE_TEXT);
        fieldDefs.add(WorkoutFields.STEP + FIELD_TYPE_INTEGER);
        fieldDefs.add(WorkoutFields.DISTANCE + FIELD_TYPE_INTEGER);
        fieldDefs.add(WorkoutFields.CALORIES + FIELD_TYPE_REAL);
        fieldDefs.add(WorkoutFields.HEART + FIELD_TYPE_INTEGER);
        fieldDefs.add(WorkoutFields.MAX_HEART + FIELD_TYPE_INTEGER);
        fieldDefs.add(WorkoutFields.MIN_HEART + FIELD_TYPE_INTEGER);
        fieldDefs.add(WorkoutFields.COUNT + FIELD_TYPE_INTEGER);
        fieldDefs.add(WorkoutFields.DURATION + FIELD_TYPE_INTEGER);
        fieldDefs.add(WorkoutFields.SPORTS_TYPE + FIELD_TYPE_INTEGER);
        fieldDefs.add(WorkoutFields.PACE + FIELD_TYPE_INTEGER);
        fieldDefs.add(WorkoutFields.VER_SPEED + FIELD_TYPE_INTEGER);
        fieldDefs.add(WorkoutFields.FREQUENCY + FIELD_TYPE_INTEGER);
        fieldDefs.add(WorkoutFields.STRIDE + FIELD_TYPE_INTEGER);
        fieldDefs.add(WorkoutFields.LONGEST_STREAK + FIELD_TYPE_INTEGER);
        fieldDefs.add(WorkoutFields.TRIPPED + FIELD_TYPE_INTEGER);
        fieldDefs.add(WorkoutFields.JUMP_ROPE_FREQUENCY + FIELD_TYPE_INTEGER);
        fieldDefs.add(WorkoutFields.SWIM_TYPE + FIELD_TYPE_INTEGER);
        fieldDefs.add(WorkoutFields.SWIM_POOL_LENGTH + FIELD_TYPE_INTEGER);
        fieldDefs.add(WorkoutFields.TRIP_TIMES + FIELD_TYPE_INTEGER);
        fieldDefs.add(WorkoutFields.SWIM_AVERAGE_SWOLF + FIELD_TYPE_INTEGER);
        fieldDefs.add(WorkoutFields.ALTITUDE + FIELD_TYPE_INTEGER);
        fieldDefs.add(WorkoutFields.HIGHEST_ALTITUDE + FIELD_TYPE_INTEGER);
        fieldDefs.add(WorkoutFields.LOWEST_ALTITUDE + FIELD_TYPE_INTEGER);
        fieldDefs.add(WorkoutFields.TOTAL_RISE_HEIGHT + FIELD_TYPE_INTEGER);
        fieldDefs.add(WorkoutFields.TOTAL_DROP_HEIGHT + FIELD_TYPE_INTEGER);
        fieldDefs.add(WorkoutFields.FLOORS_UP + FIELD_TYPE_INTEGER);
        fieldDefs.add(WorkoutFields.FLOORS_DOWN + FIELD_TYPE_INTEGER);
        fieldDefs.add(WorkoutFields.PULL_TIME + FIELD_TYPE_INTEGER);
        fieldDefs.add(WorkoutFields.FREE_TIME + FIELD_TYPE_INTEGER);
        fieldDefs.add(WorkoutFields.SPORT_ID + FIELD_TYPE_INTEGER);
        fieldDefs.add(WorkoutFields.GPS_DATA + FIELD_TYPE_TEXT);
        fieldDefs.add(WorkoutFields.DETAIL_DATA + FIELD_TYPE_TEXT);
    }

    public WorkoutModel(WorkoutData data) {
        startTime = data.getStartTime();
        endTime = data.getEndTime();
        calendar = data.getCalendar();
        step = data.getStep();
        distance = data.getDistance();
        calories = data.getCalories();
        heart = data.getHeart();
        maxHeart = data.getMaxHeart();
        minHeart = data.getMinHeart();
        count = data.getCount();
        duration = data.getDuration();
        sportsType = data.getSportsType();
        pace = data.getPace();
        verSpeed = data.getVerSpeed();
        frequency = data.getFrequency();
        stride = data.getStride();
        longestStreak = data.getLongestStreak();
        tripped = data.getTripped();
        jumpRopeFrequency = data.getJumpRopeFrequency();
        swimType = data.getSwimType();
        swimPoolLength = data.getSwimPoolLength();
        tripTimes = data.getTripTimes();
        swimAverageSwolf = data.getSwimAverageSwolf();
        altitude = data.getAltitude();
        highestAltitude = data.getHighestAltitude();
        lowestAltitude = data.getLowestAltitude();
        totalRiseHeight = data.getTotalRiseHeight();
        totalDropHeight = data.getTotalDropHeight();
        floorsUp = data.getFloorsUp();
        floorsDown = data.getFloorsDown();
        pullTime = data.getPullTime();
        freeTime = data.getFreeTime();
        freeTime = data.getFreeTime();
        gpsDataList = data.getGpsDataList();
        detailDataList = data.getRecordDetailDataList();
    }

    public static class WorkoutFields implements Fields {
        public static final String START_TIME = "start_time";
        public static final String END_TIME = "end_time";
        public static final String CALENDAR = "calendar";
        public static final String STEP = "step";
        public static final String DISTANCE = "distance";
        public static final String CALORIES = "calories";
        public static final String HEART = "heart";
        public static final String MAX_HEART = "max_heart";
        public static final String MIN_HEART = "min_heart";
        public static final String COUNT = "count";
        public static final String DURATION = "duration";
        public static final String SPORTS_TYPE = "sports_type";
        public static final String PACE = "pace";
        public static final String VER_SPEED = "ver_speed";
        public static final String FREQUENCY = "frequency";
        public static final String STRIDE = "stride";
        public static final String LONGEST_STREAK = "longest_streak";
        public static final String TRIPPED = "tripped";
        public static final String JUMP_ROPE_FREQUENCY = "jump_rope_frequency";
        public static final String SWIM_TYPE = "swim_type";
        public static final String SWIM_POOL_LENGTH = "swim_pool_length";
        public static final String TRIP_TIMES = "trip_times";
        public static final String SWIM_AVERAGE_SWOLF = "swim_average_swolf";
        public static final String ALTITUDE = "altitude";
        public static final String HIGHEST_ALTITUDE = "highest_altitude";
        public static final String LOWEST_ALTITUDE = "lowest_altitude";
        public static final String TOTAL_RISE_HEIGHT = "total_rise_height";
        public static final String TOTAL_DROP_HEIGHT = "total_drop_height";
        public static final String FLOORS_UP = "floors_up";
        public static final String FLOORS_DOWN = "floors_down";
        public static final String PULL_TIME = "pull_time";
        public static final String FREE_TIME = "free_time";
        public static final String SPORT_ID = "sport_id";
        public static final String GPS_DATA = "gps_data";
        public static final String DETAIL_DATA = "detail_data";
    }

}
